Improved Training of Wasserstein GANs

Improved Training of Wasserstein GANs

设G是生成网络(generator),D是判别网络(critic),原始GAN的训练目标是 \[ \min_G\max_D\ \mathbb{E}_{\mathbf{x}\sim\mathbb{P}_r}[\log(D(x))]+\mathbb{E}_{\mathbf{\tilde x}\sim\mathbb{P}_g}[\log(D(\tilde x))] \] 其中\(\mathbb{P}_r\)是数据分布,\(\mathbb{P}_g\)是G生成的数据分布。

WGAN训练的目标是 \[ \min_G\max_{D\in\mathcal{D}} \mathbb{E}_{\mathbf{x}\sim\mathbb{P}_r}[D(\mathbf{x})] - \mathbb{E}_{\tilde{\mathbf{x}}\sim\mathbb{P}_g}[D(\tilde{\mathbf{x}})] \] 其中\(\mathcal{D}\)是1-Lipschitz函数的集合。最小化G实际上是最小化Wasserstein距离\(W(\mathbb{P}_r,\mathbb{P}_g)\),而最大化\(D\)实际是逼近Wasserstein距离\(W(\mathbb{P}_r,\mathbb{P}_g)\)。原始的WGAN文献中,为了让D满足Lipschitz条件,对D的参数做了裁剪,限制它们的取值范围为\([-c,c]\),这样得到的的\(D\)的集合是\(k\)-Lipschitz函数集合的子集。然而这么裁剪会产生一些问题。

  1. 会限制critic的表达能力,critic会学到非常简单的函数。
  2. \(c\)需要精细调节,否则会梯度消失或者梯度爆炸。

Properties of the optimal WGAN critic

\(D^*\)是optimal ciritic,并且假设可微。从\(\mathbb{P}_r\)\(\mathbb{P}_g\)分别采样\(x\)\(y\),令\(x_t=(1-t)x+ty\)\(t\)位于\([0,1]\)。那么 \[ \nabla D^*(x_t)=\frac{y-x_t}{||y-x_t||} \] 也就是说\(D^*\)在采样区域上的梯度是\(1\)

Gradient penalty

基于optimal critic的性质,作者提出了另一种加上Lipschitz限制的方法,直接要求D的梯度的范数在真实分布和生成分布以及它们之间的区域上接近1。在损失函数中加上对梯度大小的惩罚项 \[ L=\mathbb{E}_{\tilde{\mathbb{x}}\sim\mathbb{P}_g}[D(\tilde{\mathbb{x}})]-\mathbb{E}_{\mathbb{x}\sim\mathbb{P}_r}[D(\mathbb{x})] + \lambda\mathbb{E}_{\hat{\mathbb{x}}\sim\mathbb{P}_{\hat{\mathbb{x}}}}[(||\nabla_{\hat{\mathbb{x}}}D(\hat{\mathbb{x}})||_2-1)^2]. \] 作者建议\(\lambda​\)设成10,在D中以使用layer normalization ,而不能使用 batch normalization。

\(\hat{\mathbf{x}}\sim\mathbb{P}_{\hat{\mathbf{x}}}\)的意思是:先从\(\mathbb{P}_r\)\(\mathbb{P}_g\)采样一对真假样本\(\mathbf{x}\)\(\tilde{\mathbf{x}}\) ,从\([0,1]\)上的均匀分布采样\(\epsilon\) ,然后差值采样\(\hat{\mathbf{x}}=\epsilon\mathbf{x}+(1-\epsilon)\tilde{\mathbf{x}}\)


参考文献

  1. arxiv:1704.00028,Improved Training of Wasserstein GANs